		<div class="clearfix form-actions center" style="margin-top:15px;margin-bottom:5px;">
			<div class="col-md-offset-1 col-md-10">
			@if(!isEmpty(btn_save)){
			  	<button class="btn btn-info" type="submit" id="btn_save">
					<i class="ace-icon fa fa-check bigger-110"></i>
					${btn_save!}
				</button>
			@}

			@if(!isEmpty(btn_close)){
				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="button" id="btn_close">
					<i class="ace-icon fa fa-close bigger-110"></i>
					${btn_close!}
				</button>
			@}
			@if(!isEmpty(btn_coon)){
				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="button" id="btn_coon">
					<i class="ace-icon fa fa-check bigger-110"></i>
					${btn_coon!}
				</button>
			@}
			@if(!isEmpty(btn_test)){
				&nbsp; &nbsp; &nbsp;
				<button class="btn" type="button" id="btn_test">
					<i class="ace-icon fa fa-check bigger-110"></i>
					${btn_test!}
				</button>
			@}
			</div>
		</div>
		<script src="${basePath}/static/validate/jquery-html5Validate.js"></script>
		<script type="text/javascript">
			var layerIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引
			
			$(function(){
				$("form").html5Validate(function() {
					if($("#form_token").val()==0){
						layer.alert("表单并未修改请勿提交!", {icon: 7,title:"提示"});
						return false;
					}
					if( typeof saveBefore === 'function' ){
						saveBefore();
			        }
					$("#btn_save").attr("disabled","disabled");
					var appindex = appLoading();
					var $form = $(this);
					
					var ajax = new $ax($form.attr("data-url"), function(data){
						if (data.code === 0) {
							clearLoading(appindex);
							layer.msg(data.message, {shift: 1});
							setTimeout(function(){
								closeTab(true);
							},500);
							return false;
						} else {
							clearLoading(appindex);
							$("#btn_save").removeAttr("disabled","disabled");
							if(data.code===999){
								layer.alert(data.message, {icon: 2,title:"发生错误"});
							}
							else{
								layer.msg(data.message, {shift: 6,time:2000});
							}
							return false;
						}
					});
					ajax.data = $form.serialize();
					ajax.start();
					
					return false;
				}, {
					// novalidate: false
				});
				
				$("#btn_close").bind("click",function(){
					closeTab(("${auto_close!}" == "true") ? true : false);
				});
				//测试连接
				$("#btn_coon").on("click",function(){
					$.ajax({
						type:'POST',
						url:"/dataConnection/getConn",
						data:{
							"dbtype":$("#_dbType").val(),
							"driver":$("#_driver").val(),
							"url":$("#_url").val(),
			                "username":$("#_username").val(),
			                "password":$("#_password").val(),
			                "description":$("#_description").val()
							},
							success:function(data){
								//debugger;
								if(data.code === 0){
									//成功
									layer.msg(data.message, {shift: 1});
								} else if(data.code === 1){
									//失败
									layer.msg(data.message, {shift: 1});
								}
							},
							error:function(data){
									layer.msg("系统错误", {shift: 1});
								}
						})
					});
					//sql查询
					$("#btn_test").on("click",function(){
						$.ajax({
							type:'POST',
							url:"/dbSql/getSqlConn",
							data:{
								"db_source_id":$("#db_source_id").val(),
								"sqlstring":$("#_sqlstring").val()
								
								},
								success:function(data){
									//debugger;
									 if(data.code === 0){
										 layer.open({
							                type: 1,
							                title: '扫描添加',
							                skin: 'win',
							                area: ['300px', '160px'],
							                shade: [0.3, '#fff'],
							                content: '<div class="Manual"><div class="left">患者姓名:</div><div class="right"><input type="text" id="patientName" /></div><div class="left">队列:</div><div class="right">dfsa</div><div class="left">&nbsp;</div><div class="right"><input type="button" class="w50" id="btn_sc_add"  value="提交" onclick="search()" /></div></div>',
							                success: function (id, index) {
							                    this.enterEsc = function (event) {
							                        if (event.keyCode === 13) {
							                            search();
							                            return false;
							                        }
							                    };
							                    $(document).on('keydown', this.enterEsc);
							                },
							                end: function () {
							                    $(document).off('keydown', this.enterEsc); //解除键盘关闭事件
							                }
										}
									)} else if(data.code === 1){
										//失败
										//layer.msg(data.message, {shift: 1});
										layer.msg("查询失败", { shift: 1, time: 2000 });
									} 
								},
								error:function(data){
										layer.msg("系统错误", {shift: 1});
									}
							})
						})
				
				function closeTab(isReload){
					//未找到layerIndex代表为新增tab页
					if(typeof (layerIndex) == "undefined"){
						var tabId = "";
						var dataUrl = $("form").attr("data-url");
						if(typeof (dataUrl) == "undefined"){
							tabId = "btn_${code}_view_${id!}";
						}else if(dataUrl.indexOf("save") > 0){
							tabId = "btn_${code}_add";
						}else if(dataUrl.indexOf("update") > 0){
							tabId = "btn_${code}_edit_${id!}";
						}else{
							tabId = "btn_${code}_view_${id!}";
						}
						if(isReload){
							window.top.reloadTabById("${code!}")
						}
						window.top.autoClose(tabId,"${code!}");
					} else{
						if(isReload){
							parent.searchGrid();
						}
						parent.layer.close(layerIndex);
					}
				}
				
			});
		</script>